<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"  
      xmlns:ui="http://java.sun.com/jsf/facelets"  
      xmlns:h="http://java.sun.com/jsf/html"  
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">  
      
    <h:body>  
        <ui:composition template="WEB-INF/facelets/template.xhtml">  
            <ui:param name="title" value="View Cart"/>
            <ui:define name="content">                
                <h:form>
                    
                    <p:dataTable id="cartproducts" value="#{shoppingCart.productList}" var="product">  
  
                        <p:column sortBy="#{product.name}">  
                            <f:facet name="header">  
                                <h:outputText value="Product Name:" />  
                            </f:facet>  
                            <h:outputText value="#{product.name}" />  
                        </p:column>
                        
                        <p:column sortBy="#{product.cat}">  
                            <f:facet name="header">  
                                <h:outputText value="Product Category:" />  
                            </f:facet>  
                            <h:outputText value="#{product.cat}" />  
                        </p:column> 

                        <p:column sortBy="#{product.price}">  
                            <f:facet name="header">  
                                <h:outputText value="Price:"/>  
                            </f:facet>  
                            <h:outputText value="#{product.price}" />  
                        </p:column> 

                        <p:column>  
                            <p:commandButton value="remove" action="#{shoppingCart.removeProduct}" update="@form">
                                <f:setPropertyActionListener target="#{shoppingCart.selected}" value="#{product}" />
                            </p:commandButton>
                        </p:column> 
                        
                    </p:dataTable>
                </h:form><br/>
                <h:form>
                    <h:commandButton value="View Products" action="onViewProducts" />
                    <h:commandButton value="Empty Cart" action="#{viewCartControllerBean.doEmpty}" />
                </h:form>
            </ui:define>  
              
        </ui:composition>  
    </h:body>  
</html>  
